/**
 * 抽离路由模块
 */

import VueRouter from 'vue-router'

//导入对应的路由组件
import HomeContainer from './components/tabbar/HomeContainer.vue';
import MemberContainer from './components/tabbar/MemberContainer.vue';
import ShopcarContainer from './components/tabbar/ShopcarContainer.vue';
import SearchContainer from './components/tabbar/SearchContainer.vue';
//导入新闻资讯组件
import NewsList from './components/news/NewsList.vue';
import NewsInfo from './components/news/NewsInfo.vue';
//导入图片分享组件
import PhotoList from './components/photos/PhotoList.vue';
import PhotoInfo from './components/photos/PhotoInfo.vue';
//商品购买
import GoodsList from './components/goods/GoodsList.vue';
import GoodsInfo from './components/goods/GoodsInfo.vue';
import GoodsDesc from './components/goods/GoodsDesc.vue';
import GoodsComment from './components/goods/GoodsComment.vue';

//3.创建路由对象
var router=new VueRouter({
    routes: [   //配置路由规则
        { path: '/', redirect: '/home'}, //设置默认显示页
        //前面是 router-link to 要跳转的地址，后面是导入的要跳转的组件的名称
        { path: '/home', component:  HomeContainer},
        { path: '/member', component:  MemberContainer},
        { path: '/shopcar', component:  ShopcarContainer},
        { path: '/search', component:  SearchContainer},
        /* 
            '/home/newslist' 这个看着层级多，并不代表跳转的层级，
            只是和 router-link to='/home/newslist' 上的to的地址对应而已，只是一个标识符
        */
        //新闻资讯组件
        { path: '/home/newslist', component:  NewsList},//跳转的路由，使用表达式传参id
        { path: '/home/newsinfo/:id', component:  NewsInfo},//进入的路由接收参数id,与上配置使用
        //图片分享组件
        { path: '/home/photolist', component:  PhotoList},
        { path: '/home/photoinfo/:id', component:  PhotoInfo},
        //商品购买
        { path: '/home/goodslist', component:  GoodsList},
        //编程式导航1,2对应的配置
        //{ path: '/home/goodsinfo/:id', component:  GoodsInfo},
        //编程式导航3对应的配置
        { path: '/home/goodsinfo/:id', component:  GoodsInfo, name:'goodsinfo'},
        //商品评论和介绍
        { path: '/home/goodsdesc/:id', component:  GoodsDesc, name:'goodsdesc'},
        { path: '/home/goodscomment/:id', component:  GoodsComment, name:'goodscomment'},

    ],
    linkActiveClass: 'mui-active'   //覆盖默认的路由高亮的类，默认的类名叫做
});

// 把路由对象暴露出去
export default router;